﻿using SlamDunk.ValueObjects.Enums;
using System;

namespace SlamDunk.MES.DataDrive.Bussiness.Models.FoundationContext
{
    /// <summary>
    /// 工厂模型
    /// </summary>
    public class Facility
    {
        public string 工厂模型编号 { get; set; }
        public string 工厂模型名称 { get; set; }
        public string 工厂模型层次 { get; set; }
        public string 工厂模型类型 { get; set; }
        public string 上级节点编号 { get; set; }
        public string 描述 { get; set; }
        internal FacilityLevel FacilityLevel { get; set; }
        internal FacilityType? FacilityType { get; set; }
        public void ConverterValue()
        {
            if (!string.IsNullOrWhiteSpace(this.工厂模型层次))
            {
                this.FacilityLevel = (FacilityLevel)Enum.Parse(typeof(FacilityLevel), this.工厂模型层次.Substring(0, this.工厂模型层次.IndexOf("(", StringComparison.Ordinal)));
            }
            if (!string.IsNullOrWhiteSpace(this.工厂模型类型))
            {
                this.FacilityType = (FacilityType)Enum.Parse(typeof(FacilityType), this.工厂模型类型.Substring(0, this.工厂模型类型.IndexOf("(", StringComparison.Ordinal)));
            }
        }
    }
}
